#include <algorithm>
#include <iostream>
#include <vector>

/**
 * PAT A 1117 Eddington Number
 */

int main() {
    // Read sequence
    int num;
    scanf("%d", &num);
    std::vector<int> dist(num);
    for (int i = 0; i < num; i++) scanf("%d", &dist[i]);

    // Sort sequence and minus index
    std::sort(dist.begin(), dist.end(), std::greater<int>());
    for (int i = 0; i < num; i++) dist[i] -= i + 1; // **less than**

    // Search for first non-positive element
    std::vector<int>::iterator pos =
        std::lower_bound(dist.begin(), dist.end(), 0, std::greater<int>());
    int E = pos - dist.begin();
    printf("%d\n", E);

    return 0;
}